package random

import (
	"math/rand"
	"time"
)

const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_M"
const letters2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_*+-#.M"

/*
*
关生指定长度n随机字符串，以字母开头，包括数字和下划线_
*/
func RandomString(n int) string {
	b := make([]byte, n)
	//rand.Seed(time.Now().UnixNano())
	rand.NewSource(time.Now().UnixNano())
	for i := range b {
		b[i] = letters[rand.Intn(63)]
	}
	b[0] = letters[rand.Intn(52)]

	return string(b)

}

/*
*
关生指定长度n随机字符串，以字母开头，包括数字和下划线_
*/
func RandomPassword(n int) string {
	b := make([]byte, n)
	rand.NewSource(time.Now().UnixNano())
	for i := range b {
		b[i] = letters2[rand.Intn(68)]
	}
	b[0] = letters2[rand.Intn(52)]

	return string(b)

}
